#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	char arr[25] = { 0 }, arr1[25] = { 0 };
	int i = 0, n = 0;
	int score = 0;
	int max = 0;
	int j = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d %s", &score, &arr);
		if (score > max)
		{
			for (j = 0; j < 25; j++)
			{
				arr1[j] =0;
			}
			max = score;
			for (j = 0; j <25; j++)
			{
				arr1[j] = arr[j];
			}
			for (j = 0; j < 25; j++)
			{
				arr[j] = 0;
			}
		}
	}
	for (j = 0; j <25; j++)
	{
		printf("%c", arr1[j]);
	}
	return 0;
}

